package com.richie696.dao;

import com.richie696.domain.RoleInfo;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.mybatis.caches.redis.RedisCache;

import java.util.List;

@CacheNamespace(implementation = RedisCache.class)
public interface RoleDAO {

    @Select("select * from role_info a inner join user_role_info b on a.id = b.role_id where b.user_id = #{userId}")
    @Results({
            @Result(property = "id", column = "id", id = true),
            @Result(property = "name", column = "name"),
            @Result(property = "desc", column = "desc")
    })
    List<RoleInfo> findRolesByUserId(Long userId);

}
